# -*- coding:utf-8 -*-

import requests
from bs4 import BeautifulSoup
import random

cashMap = {}

def getGifPath(key="defkey"):


    html = requests.get(url='https://multi.xnxx.com/gifs/')
    page_text = html.text
    # print(page_text)
    soup = BeautifulSoup(page_text, 'html.parser')
    select = soup.select('#Gallery  a')
    print(select)
    all = []
    for a in select:
        print(a)
        all.append(a['href'])

    print(all)
    randint = random.randint(0, len(all))
    print(randint)
    aurl = all[randint]
    print(aurl)
    aurl = aurl.replace(".jpg",".mp4")
    return aurl




def getlistgif(key="1"):
    html = requests.get(url='https://multi.xnxx.com/gifs/p-'+key)
    page_text = html.text
    soup = BeautifulSoup(page_text, 'html.parser')
    select = soup.select('#Gallery  a')
    # print(select)
    all = []
    for a in select:
        all.append(a['href'])
    # print(all)
    allmp4 = []
    for aurl in all :
        aurl = aurl.replace(".jpg",".mp4")
        allmp4.append(aurl)
    return all , allmp4


if __name__ == '__main__':
    print(getGifPath("aaa"))